package com.one.square.core.utils;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.one.square.core.domain.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author cwm
 * @Description
 * @date 2021/10/26 上午10:59
 * @Version 1.0
 */
public class HttpUtils {
    public static void writer(Result result, HttpServletResponse response) throws IOException{
        response.setContentType("application/json,charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        response.setStatus(result.getCode());
        response.getWriter().print(JSONUtil.toJsonStr(result));
    }
}
